This section describes the functions that track user activity in the close box and that close and dispose of windows.
When you no longer need a window, call the CloseWindow function (CloseWindow) if you allocated the memory for the window record or the DisposeWindow function (DisposeWindow) if you did not.
Tracks the cursor when the user presses the mouse button while the cursor is in the close box.
pascal Boolean TrackGoAway (WindowPtr theWindow,
Point thePt);
The TrackGoAway function tracks cursor activity when the user presses the mouse button while the cursor is in the close box, retaining control until the user releases the mouse button. While the button is down, TrackGoAway highlights the close box as long as the cursor is in the close region.
When the mouse button is released, TrackGoAway removes the highlighting from the close box and returns true if the cursor is within the close region and false if it is not.
Your application calls the TrackGoAway function when it receives a result code of inGoAway from the FindWindow function (FindWindow) . If TrackGoAway returns true , your application calls its own function for closing a window, which can call either the CloseWindow function (CloseWindow) or the DisposeWindow function (DisposeWindow) to remove the window from the screen. (Before removing a document window, your application ordinarily checks whether the document has changed since the associated file was last saved. See the chapter "Introduction to File Management" in Inside Macintosh: Files for a general discussion of handling files.) If TrackGoAway returns false , your application does nothing.
You can set the global variable DragHook to point to an optional function, defined by your application, which will be called by TrackGoAway as long as the mouse button is held down. (If there's an actionProc function, the actionProc function is called first.) Note that the use of the Window Manager's global variables is not guaranteed to be compatible with system software versions later than System 6.
Removes a window if you allocated memory yourself for the window's window record.
pascal void CloseWindow (WindowPtr theWindow);
The CloseWindow function removes the specified window from the screen and deletes it from the window list. It releases the memory occupied by all data structures associated with the window except the window record itself.
If you allocated memory for the window record and passed a pointer to it as one of the parameters to the functions that create windows, call CloseWindow when you're done with the window. You must then call the Memory Manager routine DisposePtr to release the memory occupied by the window record.
If your application allocated any other memory for use with a window, you must release it before calling CloseWindow . The Window Manager releases only the data structures it created.
Also, CloseWindow assumes that any picture pointed to by the window record field windowPic is data, not a resource, and it calls the QuickDraw function KillPicture to delete it. If your application uses a picture stored as a resource, you must release the memory it occupies with the ReleaseResource function and set the windowPic field to nil before closing the window.
Any pending update events for the window are discarded. If the window being removed is the frontmost window, the window behind it, if any, becomes the active window.
Removes a window if you let the Window Manager allocate memory for the window record.
pascal void DisposeWindow (WindowPtr theWindow);
The DisposeWindow function calls CloseWindow (CloseWindow) to remove a window from the screen and deletes it from the window list, then releases the memory occupied by all structures associated with the window, including the window record.
If your application allocated any other memory for use with a window, you must release it before calling DisposeWindow . The Window Manager releases only the data structures it created.
The DisposeWindow function assumes that any picture pointed to by the window record field windowPic is data, not a resource, and it calls the QuickDraw function KillPicture to delete it. If your application uses a picture stored as a resource, you must release the memory it occupies with the ReleaseResource function and set the windowPic field to nil before closing the window.
Any pending update events for the window are discarded. If the window being removed is the frontmost window, the window behind it, if any, becomes the active window.